<?php

use App\Http\Controllers\admin\ActivityController;
use App\Http\Controllers\admin\AdminController;
use App\Http\Controllers\admin\ColumnController;
use App\Http\Controllers\admin\CouponController;
use App\Http\Controllers\admin\CourseController;
use App\Http\Controllers\admin\HireController;
use App\Http\Controllers\admin\InformationController;
use App\Http\Controllers\admin\LiveController;
use App\Http\Controllers\admin\NodeController;
use App\Http\Controllers\admin\PostController;
use App\Http\Controllers\admin\ProductController;
use App\Http\Controllers\admin\SettingController;
use App\Http\Controllers\admin\TypeController;
use App\Http\Controllers\admin\UserController;
use App\Http\Controllers\admin\VideoController;
use App\Http\Controllers\admin\VipController;
use App\Http\Controllers\IndexController;
use App\Http\Controllers\InformationController as ControllersInformationController;
use App\Http\Controllers\LiveController as ControllersLiveController;
use App\Http\Controllers\PostController as ControllersPostController;
use App\Http\Controllers\ProductController as ControllersProductController;
use App\Http\Controllers\SmsController;
use App\Http\Controllers\UploadFileController;
use App\Http\Controllers\WechatLoginController;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::post('/test', [App\Http\Controllers\TestController::class, 'index'])->middleware('cors');
Route::post('/video/callback', [App\Http\Controllers\CallBackController::class, 'video']);

Route::get('/index', [IndexController::class, 'index'])->middleware('cors');
Route::post('/sms', [SmsController::class, 'index']);
Route::get('/wechat/login', [WechatLoginController::class, 'redirectToWechat']);
Route::get('/wechat/callback', [WechatLoginController::class, 'handleWechatCallback']);

Route::post('/pay/wechatNotify', [App\Http\Controllers\WechatPayController::class, 'wechatNotify']);


Route::post('/type', [App\Http\Controllers\TypeController::class, 'index'])->middleware('cors');

Route::post('/hire', [App\Http\Controllers\HireController::class, 'index'])->middleware('cors');

Route::get('/course/info/{id}', [App\Http\Controllers\CourseController::class, 'show'])->middleware('cors');
Route::post('/course', [App\Http\Controllers\CourseController::class, 'index'])->middleware('cors');

Route::get('/information/info/{id}', [ControllersInformationController::class, 'show'])->middleware('cors');
Route::post('/information', [ControllersInformationController::class, 'index'])->middleware('cors');

Route::get('/posts/{id}', [ControllersPostController::class, 'show'])->middleware('cors');
Route::post('/posts', [ControllersPostController::class, 'index'])->middleware('cors');

Route::get('/live/{id}', [ControllersLiveController::class, 'show'])->middleware('cors');
Route::post('/live', [ControllersLiveController::class, 'index'])->middleware('cors');

Route::get('/product/info/{id}', [ControllersProductController::class, 'show'])->middleware('cors');
Route::post('/product', [ControllersProductController::class, 'index'])->middleware('cors');

Route::get('/order/{id}', [App\Http\Controllers\OrderController::class, 'show'])->middleware('cors');
Route::post('/setting', [App\Http\Controllers\SettingController::class, 'index'])->middleware('cors');
Route::post('/vip', [App\Http\Controllers\VipController::class, 'index'])->middleware('cors');

Route::post('/login', [App\Http\Controllers\UserController::class, 'login'])->middleware('cors');
Route::post('/wxlogin', [App\Http\Controllers\UserController::class, 'wxlogin'])->middleware('cors');

Route::group(['middleware' => ['auth:api']], function () {

    Route::get('/user', [App\Http\Controllers\UserController::class, 'index']);
    Route::patch('/user', [App\Http\Controllers\UserController::class, 'update']);
    Route::post('/WxAppOneLoad', [UploadFileController::class, 'WxAppOneLoad'])->middleware('cors');
    Route::post('/user/getuserphonenumber', [App\Http\Controllers\UserController::class, 'getuserphonenumber']);

    Route::post('/pay', [App\Http\Controllers\WechatPayController::class, 'index'])->middleware('cors');
    Route::post('/payVip', [App\Http\Controllers\WechatPayController::class, 'vip'])->middleware('cors');

    Route::post('/ispay', [App\Http\Controllers\WechatPayController::class, 'ispay'])->middleware('cors');

    Route::post('/user/course/pay', [App\Http\Controllers\CourseController::class, 'pay'])->middleware('cors');
    Route::post('/user/course/record', [App\Http\Controllers\CourseController::class, 'record'])->middleware('cors');
    Route::post('/user/course/study', [App\Http\Controllers\CourseController::class, 'study'])->middleware('cors');


    Route::post('/user/information/pay', [ControllersInformationController::class, 'pay'])->middleware('cors');

    Route::post('/user/order', [App\Http\Controllers\OrderController::class, 'index'])->middleware('cors');
    Route::put('/user/order', [App\Http\Controllers\OrderController::class, 'store'])->middleware('cors');
});
Route::prefix('admin')->group(function () {

    Route::post('/login', [AdminController::class, 'login'])->middleware('cors');

    Route::group(['middleware' => ['auth:admin_api']], function () {
        Route::get('/index', [AdminController::class, 'index'])->middleware('cors');
        Route::get('/upload/getToken', [UploadFileController::class, 'getToken'])->middleware('cors');
        Route::post('/upload', [UploadFileController::class, 'upload'])->middleware('cors');
        Route::get('/upload/video', [UploadFileController::class, 'video'])->middleware('cors');
        Route::post('/upload/xiumi', [UploadFileController::class, 'xiumi'])->middleware('cors');


        Route::post('/setting', [SettingController::class, 'index'])->middleware('cors');
        Route::put('/setting', [SettingController::class, 'store'])->middleware('cors');
        Route::patch('/setting', [SettingController::class, 'update'])->middleware('cors');
        Route::delete('/setting/{id}', [SettingController::class, 'delete'])->middleware('cors');


        Route::get('/user/{id}', [UserController::class, 'show'])->middleware('cors');
        Route::post('/user', [UserController::class, 'index'])->middleware('cors');

        Route::post('/type', [TypeController::class, 'index'])->middleware('cors');
        Route::put('/type', [TypeController::class, 'store'])->middleware('cors');
        Route::patch('/type', [TypeController::class, 'update'])->middleware('cors');
        Route::delete('/type/{id}', [TypeController::class, 'delete'])->middleware('cors');


        Route::get('/activity/{id}', [ActivityController::class, 'show'])->middleware('cors');
        Route::post('/activity', [ActivityController::class, 'index'])->middleware('cors');
        Route::put('/activity', [ActivityController::class, 'store'])->middleware('cors');
        Route::patch('/activity', [ActivityController::class, 'update'])->middleware('cors');
        Route::delete('/activity/{id}', [ActivityController::class, 'delete'])->middleware('cors');

        Route::get('/vip/{id}', [VipController::class, 'show'])->middleware('cors');
        Route::post('/vip', [VipController::class, 'index'])->middleware('cors');
        Route::put('/vip', [VipController::class, 'store'])->middleware('cors');
        Route::patch('/vip', [VipController::class, 'update'])->middleware('cors');
        Route::delete('/vip/{id}', [VipController::class, 'delete'])->middleware('cors');

        Route::get('/coupon/{id}', [CouponController::class, 'show'])->middleware('cors');
        Route::post('/coupon', [CouponController::class, 'index'])->middleware('cors');
        Route::put('/coupon', [CouponController::class, 'store'])->middleware('cors');
        Route::patch('/coupon', [CouponController::class, 'update'])->middleware('cors');
        Route::delete('/coupon/{id}', [CouponController::class, 'delete'])->middleware('cors');

        Route::get('/column/{id}', [ColumnController::class, 'show'])->middleware('cors');
        Route::post('/column', [ColumnController::class, 'index'])->middleware('cors');
        Route::put('/column', [ColumnController::class, 'store'])->middleware('cors');
        Route::patch('/column', [ColumnController::class, 'update'])->middleware('cors');
        Route::delete('/column/{id}', [ColumnController::class, 'delete'])->middleware('cors');

        Route::get('/course/{id}', [CourseController::class, 'show'])->middleware('cors');
        Route::post('/course', [CourseController::class, 'index'])->middleware('cors');
        Route::put('/course', [CourseController::class, 'store'])->middleware('cors');
        Route::patch('/course', [CourseController::class, 'update'])->middleware('cors');
        Route::delete('/course/{id}', [CourseController::class, 'delete'])->middleware('cors');

        Route::get('/information/{id}', [InformationController::class, 'show'])->middleware('cors');
        Route::post('/information', [InformationController::class, 'index'])->middleware('cors');
        Route::put('/information', [InformationController::class, 'store'])->middleware('cors');
        Route::patch('/information', [InformationController::class, 'update'])->middleware('cors');
        Route::delete('/information/{id}', [InformationController::class, 'delete'])->middleware('cors');

        Route::get('/node/{id}', [NodeController::class, 'show'])->middleware('cors');
        Route::post('/node', [NodeController::class, 'index'])->middleware('cors');
        Route::put('/node', [NodeController::class, 'store'])->middleware('cors');
        Route::patch('/node', [NodeController::class, 'update'])->middleware('cors');
        Route::delete('/node/{id}', [NodeController::class, 'delete'])->middleware('cors');

        Route::get('/posts/{id}', [PostController::class, 'show'])->middleware('cors');
        Route::post('/posts', [PostController::class, 'index'])->middleware('cors');
        Route::put('/posts', [PostController::class, 'store'])->middleware('cors');
        Route::patch('/posts', [PostController::class, 'update'])->middleware('cors');
        Route::delete('/posts/{id}', [PostController::class, 'delete'])->middleware('cors');

        Route::get('/live/{id}', [LiveController::class, 'show'])->middleware('cors');
        Route::post('/live', [LiveController::class, 'index'])->middleware('cors');
        Route::put('/live', [LiveController::class, 'store'])->middleware('cors');
        Route::patch('/live', [LiveController::class, 'update'])->middleware('cors');
        Route::delete('/live/{id}', [LiveController::class, 'delete'])->middleware('cors');

        Route::get('/product/{id}', [ProductController::class, 'show'])->middleware('cors');
        Route::post('/product', [ProductController::class, 'index'])->middleware('cors');
        Route::put('/product', [ProductController::class, 'store'])->middleware('cors');
        Route::patch('/product', [ProductController::class, 'update'])->middleware('cors');
        Route::delete('/product/{id}', [ProductController::class, 'delete'])->middleware('cors');

        Route::get('/video/{id}', [VideoController::class, 'show'])->middleware('cors');
        Route::post('/video', [VideoController::class, 'index'])->middleware('cors');
        Route::post('/video/all', [VideoController::class, 'all'])->middleware('cors');
        Route::put('/video', [VideoController::class, 'store'])->middleware('cors');
        Route::patch('/video', [VideoController::class, 'update'])->middleware('cors');
        Route::delete('/video/{id}', [VideoController::class, 'delete'])->middleware('cors');

        Route::get('/hire/{id}', [HireController::class, 'show'])->middleware('cors');
        Route::post('/hire', [HireController::class, 'index'])->middleware('cors');
        Route::put('/hire', [HireController::class, 'store'])->middleware('cors');
        Route::patch('/hire', [HireController::class, 'update'])->middleware('cors');
        Route::delete('/hire/{id}', [HireController::class, 'delete'])->middleware('cors');

    });

});


